<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use DateTimeInterface;

class Yaohaorecordlist extends Model
{
    protected $table = 'yaohao_record_list';
    protected $primaryKey = 'id';

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'm月d日H点i分');
    }
    
    public static function getYaohaoRecordList($openid)
    {
        return self::where("openid",$openid)->where("disable",1)->get();
    }

    public static function yaohaoRecordListCreate($openid,$code,$city)
    {
        return self::insert(["openid"=>$openid,"code"=>$code,"city"=>$city,"created_at"=>time()]);
    }

    public static function yaohaoRecordListDelete($openid,$code)
    {
        return self::where("openid",$openid)->where("code",$code)->delete();
    }
}